#include "XML/GUIXMLCursorHandler.h"
#include "GUIError.h"
#include "GUIBase.h"
#include <Windows.h>
#include "include/GUIMouseCursor.h"

namespace YGUI
{
    CursorXMLHandler::CursorXMLHandler(void)
    {
    }

    CursorXMLHandler::~CursorXMLHandler(void)
    {
    }

    unsigned long CursorXMLHandler::elementStart(const XMLAttribute& attri)
    {
        if(CursorElement == attri.getElementValue())
            return cursorElementStart(attri);
        return ERRORCODE::GUI_ERROR_SUCCESS;
    }

    void CursorXMLHandler::elementEnd(const XMLAttribute& attri)
    {
    }

    unsigned long CursorXMLHandler::cursorElementStart(const XMLAttribute& attri)
    {
        const String& name = attri.getValue(NameAttribute);
        const String& value = attri.getValue(ValueAttribute);
        const String& type = attri.getValue(TypeAttribute);
        if(type == ImageType)
            MouseCursor::getSingleton().addCursor(name, MouseCursor::RT_Image, value);
        else if(type == AnimationType)
            MouseCursor::getSingleton().addCursor(name, MouseCursor::RT_Animation, value);
        return ERRORCODE::GUI_ERROR_SUCCESS;
    }
}

const YGUI::String YGUI::CursorXMLHandler::CursorElement("Cursor");
const YGUI::String YGUI::CursorXMLHandler::NameAttribute("name");
const YGUI::String YGUI::CursorXMLHandler::TypeAttribute("type");
const YGUI::String YGUI::CursorXMLHandler::ValueAttribute("value");
const YGUI::String YGUI::CursorXMLHandler::ImageType("image");
const YGUI::String YGUI::CursorXMLHandler::AnimationType("animation");
